package com.mane.exception;

import com.mane.entity.Result;
import io.swagger.v3.oas.annotations.Hidden;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Hidden
@RestControllerAdvice
@Slf4j
public class HandleExceptionAdvice {

    @ExceptionHandler(Exception.class)
    public Result handleException(Exception e) throws Exception {
        // 排除 Swagger 相关的异常
        if (e instanceof IllegalStateException || e instanceof IllegalArgumentException) {
            throw e; // 重新抛出 Swagger 相关的异常
        }
        log.debug(e.getMessage());
        return Result.error("服务器繁忙，请稍后再试");
    }
}
